import sys

import pandas as pd

stockName = sys.argv[1]

data = pd.read_excel('D:/stock/data/' + stockName + '.xls')

startDate = sys.argv[2]
endDate = sys.argv[3]

startIndex = 0
endIndex = 0

dataList = data['everyDate']
for i in range(len(dataList)):
    if startDate >= dataList[i]:
        startIndex = i
    if endDate <= dataList[i]:
        endIndex = i
        break

MA = data[['everyDate', 'MA5', 'MA10', 'MA20', 'MA30', 'MA60', 'MA120', 'MA250']]
MAList = MA[startIndex:endIndex + 1].values.tolist()

with open("D:/stock/MA__" + stockName + ".txt", "w") as f:
    for i in range(len(MAList)):
        for j in MAList[i]:
            f.write(str(j) + "\t")
        f.write("\n")
